package com.jz.community.moduleexpress.express.ui;

import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.flyco.tablayout.SlidingTabLayout;
import com.jz.community.basecomm.base.BaseMvpActivity;
import com.jz.community.basecomm.mvp.BaseMvpPresenter;
import com.jz.community.commview.commPagerAdapter.CommonViewPagerAdapter;
import com.jz.community.moduleexpress.R;
import com.jz.community.moduleexpress.R2;

import butterknife.BindView;

/**
 * Created by Tony.Fan on 2018/8/1 17:14
 */
public class ExpressHistoryActivity extends BaseMvpActivity {

    @BindView(R2.id.express_history_tab)
    SlidingTabLayout expressHistoryTab;
    @BindView(R2.id.express_history_viewpager)
    ViewPager expressHistoryViewpager;
    @BindView(R2.id.title_back_left)
    ImageView titleBackLeft;
    @BindView(R2.id.title_name)
    TextView titleName;
    @BindView(R2.id.title_right)
    TextView titleRight;
    @BindView(R2.id.title_toolbar)
    Toolbar titleToolbar;

    private String[] titles = {"待支付", "待出库", "已寄出", "已取消"};

    @Override
    protected int getContentView() {
        return R.layout.module_express_express_history_layout;
    }

    @Override
    protected void initView() {
        titleName.setText("寄件记录");
        setImmersionBar(titleToolbar);
    }

    @Override
    protected void addListener() {
        super.addListener();
        titleBackLeft.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    protected void initDatas() {
        super.initDatas();
        initViewPager();
    }

    private void initViewPager() {
        CommonViewPagerAdapter viewPagerAdapter = new CommonViewPagerAdapter(getSupportFragmentManager());
        for (int i = 0; i < titles.length; i++) {
            ExpressHistoryFragment orderListFragment = ExpressHistoryFragment.newInstance(i);
            viewPagerAdapter.addFragment(orderListFragment, i);
        }
        expressHistoryViewpager.setOffscreenPageLimit(4);
        expressHistoryViewpager.setAdapter(viewPagerAdapter);
        expressHistoryTab.setViewPager(expressHistoryViewpager, titles);
    }

    @Override
    protected BaseMvpPresenter createPresenter() {
        return null;
    }
}
